CLASS lhc_ymoon_production DEFINITION INHERITING FROM cl_abap_behavior_handler.
  PRIVATE SECTION.

    METHODS get_instance_authorizations FOR INSTANCE AUTHORIZATION
      IMPORTING keys REQUEST requested_authorizations FOR ymoon_production RESULT result.

    METHODS read FOR READ
      IMPORTING keys FOR READ ymoon_production RESULT result.

    METHODS lock FOR LOCK
      IMPORTING keys FOR LOCK ymoon_production.
    METHODS order_release FOR READ
      IMPORTING keys FOR FUNCTION ymoon_production~order_release RESULT result.
    METHODS order_release2 FOR MODIFY
      IMPORTING keys FOR ACTION ymoon_production~order_release2 RESULT result.

ENDCLASS.

CLASS lhc_ymoon_production IMPLEMENTATION.

  METHOD get_instance_authorizations.
  ENDMETHOD.

  METHOD read.
  ENDMETHOD.

  METHOD lock.
  ENDMETHOD.

  METHOD order_release.

    MODIFY ENTITIES OF i_productionordertp ENTITY productionorder
      EXECUTE release
      FROM VALUE #( ( productionorder = '000001000082' ) )
      RESULT DATA(lt_result)
      MAPPED DATA(lt_mapped)
      FAILED DATA(lt_failed)
      REPORTED DATA(lt_reported).


  ENDMETHOD.

  METHOD order_release2.
    DATA:lv_aufnr_str TYPE string.
    DATA:BEGIN OF ls_aufnr,
           aufnr TYPE c LENGTH 12,
         END OF ls_aufnr.
    DATA:lt_aufnr LIKE TABLE OF ls_aufnr.
    DATA(key) = keys[ 1 ].
    DATA(param) = key-%param.
    lv_aufnr_str = param-productionorder. "|{ param-productionorder  ALPHA = IN }|.
    SPLIT lv_aufnr_str AT ',' INTO TABLE lt_aufnr.

    LOOP AT lt_aufnr INTO ls_aufnr.
      MODIFY ENTITIES OF i_productionordertp ENTITY productionorder
      EXECUTE release
      FROM VALUE #( ( productionorder = |{ ls_aufnr-AUFNR ALPHA = IN }| ) )
      RESULT DATA(lt_result)
      MAPPED DATA(lt_mapped)
      FAILED DATA(lt_failed)
      REPORTED DATA(lt_reported).

      IF lt_failed-productionorder[] IS NOT INITIAL.
        LOOP AT lt_reported-productionorder INTO DATA(ls_line).
          IF ls_line-%msg->if_t100_dyn_msg~msgty = 'E'.
            MESSAGE ID ls_line-%msg->if_t100_message~t100key-msgid TYPE ls_line-%msg->if_t100_dyn_msg~msgty NUMBER ls_line-%msg->if_t100_message~t100key-msgno
                INTO DATA(mtext)
                WITH ls_line-%msg->if_t100_dyn_msg~msgv1 ls_line-%msg->if_t100_dyn_msg~msgv1 ls_line-%msg->if_t100_dyn_msg~msgv1 ls_line-%msg->if_t100_dyn_msg~msgv1.

            APPEND VALUE #(    %cid = key-%cid %param = VALUE #( result = 'E' message = mtext ) ) TO result .
          ENDIF.
        ENDLOOP.
      ELSE.
        APPEND VALUE #(   %cid = key-%cid %param = VALUE #( result = 'S' message = 'Release!!!' ) ) TO result.
      ENDIF.
    ENDLOOP.


  ENDMETHOD.


ENDCLASS.

CLASS lsc_ymoon_production DEFINITION INHERITING FROM cl_abap_behavior_saver.
  PROTECTED SECTION.

    METHODS finalize REDEFINITION.

    METHODS check_before_save REDEFINITION.

    METHODS save REDEFINITION.

    METHODS cleanup REDEFINITION.

    METHODS cleanup_finalize REDEFINITION.

ENDCLASS.

CLASS lsc_ymoon_production IMPLEMENTATION.

  METHOD finalize.
  ENDMETHOD.

  METHOD check_before_save.
  ENDMETHOD.

  METHOD save.
  ENDMETHOD.

  METHOD cleanup.
  ENDMETHOD.

  METHOD cleanup_finalize.
  ENDMETHOD.

ENDCLASS.
